package com.yy.mypro.controller;


import com.yy.mypro.domain.po.Stu;
import com.yy.mypro.services.StuServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;



@RestController
@CrossOrigin
@RequestMapping("/stu")
public class StuController {

    @Autowired
    StuServices stuServices;

    //todo 学生全查询
    @GetMapping("getAll")
    public Object getAll(){
        List<Stu> stus = stuServices.getAll();
        return stus;
    }
    //todo 学生按照ID查询
    @GetMapping("get")
    public Object get(int id){
        Stu stu = stuServices.get(id);
        return stu;
    }
    //todo 学生添加
    @PostMapping("add")
    public Object add(Stu stu){
        stuServices.add(stu);
        return "添加成功!!!!!";
    }
    //todo 学生修改
    @PostMapping("edit")
    public Object edit(Stu stu){
        stuServices.edit(stu);
        return "修改成功!!!!!";
    }

    //todo 学生删除
    @GetMapping("del")
    public Object del(int id){
        stuServices.del(id);
        return "删除成功!!!!!";
    }
}

